package consts

import (
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"log"
)

/*
	db常量配置
*/
const HOST = "118.89.73.150"
const PORT = "1118"
const DATABASENAME = "cwb_biz"
const USER = "root"
const PASSWORD = "YourNewPassword!"

/*
*	获取db对象
 */
func GetGormDB() *gorm.DB {
	connection := USER + ":" + PASSWORD + "@tcp(" + HOST + ":" + PORT + ")/" + DATABASENAME + "?charset=utf8mb4&parseTime=True&loc=Local"
	db, err := gorm.Open(mysql.Open(connection), &gorm.Config{})
	if err != nil {
		panic("failed to connect database")
	} else {
		log.Print("collect database successful")
	}
	return db
}
